<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>


<div id="content">
	<table class="rowTable" cellspacing="0" >
		<tr>
			<th>고객명 </th>
			<td><input type="text" id="cust_nm" /></td>
			<th>주민 번호</th>
			<td>
				<input type="text" id="ssn1" />&nbsp;&nbsp;-&nbsp;&nbsp;
				<input type="text" id="ssn2" />
			</td>
		</tr>
		<tr>
			<th>사용중인 번호</th>
			<td><input type="text" id="telno" />&nbsp;&nbsp;<b style="color: blue;">* 02-000-0000</b></td>
			<th>가입 구분</th>
			<td>
				<select id="buy_type"></select>
			</td>
		</tr>
		<tr>
			<th>할부/완납</th>
			<td><span id="div_type_list"></span></td>
			<th>통신사</th>
			<td>
				<select id="telco"></select>
			</td>
		</tr>
		<tr>
			<th>미성년자</th>
			<td>
				<input type="radio" name="audlt_yn" id="adult_yn1" value="Y" checked /><label for="adult_yn1">미성년자 아님</label>
				<input type="radio" name="audlt_yn" id="adult_yn2" value="N" /><label for="adult_yn2">미성년자 입니다.</label>
			</td>
			<th>법정 대리인 이름</th>
			<td>
				<input type="text" id="lawer_nm" />
			</td>
		</tr>
		<tr>
			<th>법정 대리인 주민번호</th>
			<td>
				<input type="text" id="lawer_ssn1" />&nbsp;&nbsp;-&nbsp;&nbsp;
				<input type="text" id="lawer_ssn2" />
			</td>
			<th>법정 대리인 연락처</th>
			<td><input type="text" id="lawer_telno" /></td>
		</tr>
		<tr>
			<td colspan="4"><span class="button black"><button type="button" id="authRequestBtn">신용조회 요청</button></span></td>
		</tr>
	</table>
</div>


<script type="text/javascript">
$(document).ready(function(){
	getSelectCodeList('buy_type', 'buy_type');
	getSelectCodeList('telco', 'telco');
	getRadioCodeList('div_type', 'div_type_list');
});

$(function(){
	$('#authRequestBtn').click(function(){
		$.ajax({
			url: 'credit.do',
			type: "POST",
			dataType:"json",
			data: {
				method        : 'insert',
				cust_nm       : $('#cust_nm').val(),
				cust_no       : $('#ssn1').val() + "-" + $('#ssn2').val(),
				telno         : $('#telno').val(),
				div_type      : $('input:[name=div_type]:checked').val(),
				buy_type      : $('#buy_type').val(),
				telco         : $('#telco').val(),
				audlt_yn      : $('input:[name=audlt_yn]:checked').val(),
				lawer_nm      : $('#lawer_nm').val(),
				lawer_cust_no : $('#lawer_ssn1').val() + "-" + $('#lawer_ssn2').val(),
				lawer_telno   : $('#lawer_telno').val()
			},
			indicator: true,
			success: function(jsonData, status, xhr){
				$.each(jsonData, function(idx, e){
					if(e.resultCode == '1000') {
						alertDialog("요청 완료 하였습니다.");
						$('input:text, select').val('');
					}else {
						alertDialog("요청 실패 하였습니다.");
					}
				});
			},
			error:function(xhr, status, e){
				alertDialog("요청 실패 하였습니다.");
			}
		});
	});
});
</script>
